home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / lib / Intmap.sig < prev    next >
Encoding:
Text File  |  1997-08-18  |  2.2 KB  |  67 lines  |  [TEXT/Moml]

  1. (* Intmap -- Applicative maps with integer keys.
  2.  *
  3.  * Modified for Moscow ML from SML/NJ library v. 0.2 which is 
  4.  * COPYRIGHT (c) 1993 by AT&T Bell Laboratories.
  5.  * Original implementation due to Stephen Adams, Southampton, UK.
  6.  *)
  7.  
  8. type 'a intmap
  9.  
  10. exception NotFound
  11.  
  12. val empty     : unit -> 'a intmap
  13. val insert    : 'a intmap * int * 'a -> 'a intmap
  14. val retrieve  : 'a intmap * int -> 'a
  15. val peek      : 'a intmap * int -> 'a option
  16. val remove    : 'a intmap * int -> 'a intmap * 'a
  17. val numItems  : 'a intmap ->  int
  18. val listItems : 'a intmap -> (int * 'a) list
  19. val app       : (int * 'a -> unit) -> 'a intmap -> unit
  20. val revapp    : (int * 'a -> unit) -> 'a intmap -> unit
  21. val foldr     : (int * 'a * 'b -> 'b) -> 'b -> 'a intmap -> 'b
  22. val foldl     : (int * 'a * 'b -> 'b) -> 'b -> 'a intmap -> 'b
  23. val map       : (int * 'a -> 'b) -> 'a intmap -> 'b intmap
  24. val transform : ('a -> 'b) -> 'a intmap -> 'b intmap
  25.  
  26.  
  27. (* Type 'a intmap is the type of applicative maps from int to 'a.
  28.  
  29.    [empty] creates a new empty map.
  30.  
  31.    [insert(m, i, v)] extends (or modifies) map m to map i to v.
  32.  
  33.    [retrieve(m, i)] returns v if m maps i to v; otherwise raises
  34.    NotFound.
  35.  
  36.    [peek(m, i)] returns SOME v if m maps i to v; otherwise NONE.
  37.  
  38.    [remove(m, i)] removes i from the domain of m and returns the
  39.    modified map and the element v corresponding to i.  Raises NotFound
  40.    if i is not in the domain of m.
  41.  
  42.    [numItems m] returns the number of entries in m (that is, the size
  43.    of the domain of m).
  44.  
  45.    [listItems m] returns a list of the entries (i, v) of integers i and
  46.    the corresponding values v in m.
  47.  
  48.    [app f m] applies function f to the entries (i, v) in m, in
  49.    increasing order of i.
  50.  
  51.    [revapp f m] applies function f to the entries (i, v) in m, in
  52.    decreasing order of i.
  53.  
  54.    [foldl f e m] applies the folding function f to the entries (i, v)
  55.    in m, in increasing order of i.
  56.  
  57.    [foldr f e m] applies the folding function f to the entries (i, v)
  58.    in m, in decreasing order of i.
  59.  
  60.    [map f m] returns a new map whose entries have form (i, f(i,v)),
  61.    where (i, v) is an entry in m.
  62.  
  63.    [transform f m] returns a new map whose entries have form (i, f(i,v)),
  64.    where (i, v) is an entry in m.
  65.  
  66. *)
  67.